<?php
/*
*  -------------------------------------------------
*   @file		: .php
*   @link		:CPC  www.chinapet.com
*   @copyright	: 2002-2012 Xingmo Inc
*   @author		: Laipiyang <462166282@qq.com>
*   @blog_url   : http://www.icuir.com/
*   @blog_url   : http://blog.sina.com.cn/xmphp
*   @date		:
*   @update		:
*  -------------------------------------------------
*/
require_once "config.php";
$filename=basename(__FILE__);
$act=isset ( $_GET['act'] ) ? trim ( $_GET['act'] ) : '' ;
if($act=='add')
{
	$id=isset ( $_GET['id'] ) ? intval ( $_GET['id'] ) : 0 ;
	if($id<1)
	{
		noalert('.');
		exit;
	}

	$smarty->assign('id',$id);
	$smarty->assign('a',array('title'=>'添加分类','act'=>'insert','btn'=>'添加分类'));
	$smarty->display(ADMIN_TPL.'sort_info.dwt');

}
else if ($act=='insert')
{
	$name=isset ( $_POST['sort_name'] ) ? trim ( $_POST[''] ) : '' ;
}

function get_sort($id=0,$table='sort',$t=-1)
{
	$t++;
	static $lcc=array();
	$sql="SELECT * FROM `{$table}` WHERE `parent_id`='{$id}'";
	$res=$db->getAll($sql);
    if($res)
    {
		foreach ($res as $key => $val )
		{
			if($val['parent_id']<>'0')
			{
				$val['sort_name']=str_repeat('&nbsp;&nbsp;',$t*4).'|-'.$val['sort_name'];
			}
			else
			{
				$val['sort_name']=$val['sort_name'];
			}
		  $lcc[]=$val;
		  get_sort($val['id'],$table,$t);
		}
    }
	return $lcc;
}
?>
